package luj.game.robot.internal.start.listener;

import luj.cluster.api.actor.Tellable;
import luj.game.robot.api.boot.RobotStartListener;
import luj.game.robot.internal.net.http.collect.HandleMap;

import java.util.List;

public class BotStartListenTrigger {

  public BotStartListenTrigger(List<RobotStartListener> listenerList, Tellable parentRef, Tellable adminRef, HandleMap httpHandleMap) {
    _listenerList = listenerList;
    _parentRef = parentRef;
    _adminRef = adminRef;
    _httpHandleMap = httpHandleMap;
  }

  public void trigger() {
    var ctx = new StartContextImpl();
    ctx._bossRef = _parentRef;

    ctx._adminRef = _adminRef;
    ctx._httpHandleMap = _httpHandleMap;

    for (RobotStartListener listener : _listenerList) {
      listener.onStart(ctx);
    }
  }

  private final List<RobotStartListener> _listenerList;

  private final Tellable _parentRef;
  private final Tellable _adminRef;

  private final HandleMap _httpHandleMap;
}
